import { _decorator, Component, Node } from 'cc';
import { LvLStorage } from '../../LvLStorage';
const { ccclass, property } = _decorator;

@ccclass('HouseGround')
export class HouseGround extends Component {

    private house_info:any = null;
    protected onLoad(): void {
        this.node.on(Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
        this.house_info = LvLStorage.get_house_info();
    }

    protected onTouchMove(event: any): void {
        // console.log(event);
        let delta = event.getDelta();
        let targetX:number = this.node.position.x + delta.x;
        if (targetX > -1500 && targetX < 450) {
            this.node.setPosition(this.node.position.x + delta.x, this.node.position.y, this.node.position.z);
        }
        
    }

    start() {
        // 要根据房屋数据，显示出各个房子的外观状态
        // {
        //     "build_id":1,
        //     "stage":[1,3,2,2,0]
        // }

    }
    protected onDestroy(): void {
        this.node.off(Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
    }

    update(deltaTime: number) {
        
    }
}


